
"""
    one-hot vec
    both equal one
    total num represent similarity
"""

def one_hot_vec_coequalone_num( vec1, vec2 ):
    assert len( vec1 ) == len( vec2 )

    num = 0
    for i in range( len( vec1) ):
        if vec1[i] == 1 and vec2[i] == 1:
            num += 1
    return num


def set_jaccrd( set1, set2):
    len1 = len( set1.intersection(set2) )
    len2 = len( set1.union(set2) )

    return float(len1) / len2

if __name__ == '__main__':
    y_pred = set([0, 2, 3,4])
    y_true = set([0, 1, 3])
    j1 = set_jaccrd(y_true, y_pred)
    print j1

